// 处理 kubectl 导航的核心逻辑
export async function handleKubectlCore(currentUrl) {
    // 检查URL是否符合条件
    const consoleMatch = currentUrl.match(/\/console-([^/]+)\//);
    if (!consoleMatch) {
        return {
            success: false,
            error: '请在控制台页面使用 kubectl'
        };
    }

    // 构建目标URL
    const baseUrl = currentUrl.split('/console-')[0];
    const consoleUrl = '/console-platform/terminal/cli-tools';
    const targetUrl = `${baseUrl}${consoleUrl}`;

    return {
        success: true,
        targetUrl
    };
}

// 统一的跳转处理逻辑
export async function navigateToKubectl(currentTab, targetUrl, openType = 'tab') {
    switch (openType) {
        case 'current':
            return chrome.tabs.update(currentTab.id, { url: targetUrl });
            
        case 'window':
            return chrome.windows.create({
                url: targetUrl,
                type: 'popup',
                width: 1200,
                height: 800,
                focused: true
            });
            
        case 'tab':
        default:
            return chrome.tabs.create({
                url: targetUrl,
                active: true,
                index: currentTab.index + 1
            });
    }
} 